﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Microsoft.VisualBasic;

namespace SalePartial.Model
{

    public class XPQuoteInfo
    {
        // Methods
        public XPQuoteInfo()
        {
            this._userID = Guid.Empty;
            this._companyID = Guid.Empty;
            this._inquiryID = Guid.Empty;
            this._quoteApp = string.Empty;
            this._quoteStatus = string.Empty;
            this._unitPriceByQty = string.Empty;
            this._costOfDeliverByQty = string.Empty;
            this._otherExpenseName = string.Empty;
            this._otherExpenseByQty = string.Empty;
            this._totalAmount = string.Empty;
            this._currency = string.Empty;
            this._deliveryComment = string.Empty;
            this._comment = string.Empty;
            this._attachment = string.Empty;
            this._quoteID = Guid.NewGuid();
            this._deleteDate = DateTime.MinValue.AddYears(0x76c);
            this._closeDate = DateTime.MinValue.AddYears(0x76c);
            this._submitDate = DateTime.MinValue.AddYears(0x76c);
            this._createDate = DateTime.Now;
            this._lastSaveDate = DateTime.Now;
            this.QuoteStatus = "0000000";
        }

        public XPQuoteInfo(SqlDataReader reader)
        {
            this._userID = Guid.Empty;
            this._companyID = Guid.Empty;
            this._inquiryID = Guid.Empty;
            this._quoteApp = string.Empty;
            this._quoteStatus = string.Empty;
            this._unitPriceByQty = string.Empty;
            this._costOfDeliverByQty = string.Empty;
            this._otherExpenseName = string.Empty;
            this._otherExpenseByQty = string.Empty;
            this._totalAmount = string.Empty;
            this._currency = string.Empty;
            this._deliveryComment = string.Empty;
            this._comment = string.Empty;
            this._attachment = string.Empty;
            this.LoadFromReader(reader);
        }

        //public XPQuoteInfo(Guid id)
        //{
        //    this._userID = Guid.Empty;
        //    this._companyID = Guid.Empty;
        //    this._inquiryID = Guid.Empty;
        //    this._quoteApp = string.Empty;
        //    this._quoteStatus = string.Empty;
        //    this._unitPriceByQty = string.Empty;
        //    this._costOfDeliverByQty = string.Empty;
        //    this._otherExpenseName = string.Empty;
        //    this._otherExpenseByQty = string.Empty;
        //    this._totalAmount = string.Empty;
        //    this._currency = string.Empty;
        //    this._deliveryComment = string.Empty;
        //    this._comment = string.Empty;
        //    this._attachment = string.Empty;
        //    SqlDataReader reader = XPQuoteUtility.SelectReader(id);
        //    if (reader.Read())
        //    {
        //        this.LoadFromReader(reader);
        //        reader.Close();
        //    }
        //    else
        //    {
        //        if (!reader.IsClosed)
        //        {
        //            reader.Close();
        //        }
        //        throw new ApplicationException("XPQuoteInfo does not exist.");
        //    }
        //}

        
        protected void LoadFromReader(SqlDataReader reader)
        {
            if ((!Information.IsNothing(reader) && !reader.IsClosed))
            {
                this._quoteID = reader.GetGuid(0);
                this._userID = reader.GetGuid(1);
                this._companyID = reader.GetGuid(2);
                this._inquiryID = reader.GetGuid(3);
                if (!reader.IsDBNull(4))
                {
                    this._quoteApp = reader.GetString(4);
                }
                if (!reader.IsDBNull(5))
                {
                    this._quoteStatus = reader.GetString(5);
                }
                this._createDate = reader.GetDateTime(6);
                if (!reader.IsDBNull(7))
                {
                    this._closeDate = reader.GetDateTime(7);
                }
                if (!reader.IsDBNull(8))
                {
                    this._deleteDate = reader.GetDateTime(8);
                }
                if (!reader.IsDBNull(9))
                {
                    this._submitDate = reader.GetDateTime(9);
                }
                if (!reader.IsDBNull(10))
                {
                    this._lastSaveDate = reader.GetDateTime(10);
                }
                if (!reader.IsDBNull(11))
                {
                    this._expireDate = reader.GetDateTime(11);
                }
                if (!reader.IsDBNull(12))
                {
                    this._unitPriceByQty = reader.GetString(12);
                }
                if (!reader.IsDBNull(13))
                {
                    this._costOfDeliverByQty = reader.GetString(13);
                }
                if (!reader.IsDBNull(14))
                {
                    this._otherExpenseName = reader.GetString(14);
                }
                if (!reader.IsDBNull(15))
                {
                    this._otherExpenseByQty = reader.GetString(15);
                }
                if (!reader.IsDBNull(0x10))
                {
                    this._totalAmount = reader.GetString(0x10);
                }
                if (!reader.IsDBNull(0x11))
                {
                    this._currency = reader.GetString(0x11);
                }
                if (!reader.IsDBNull(0x12))
                {
                    this._deliveryComment = reader.GetString(0x12);
                }
                if (!reader.IsDBNull(0x13))
                {
                    this._comment = reader.GetString(0x13);
                }
                if (!reader.IsDBNull(20))
                {
                    this._attachment = reader.GetString(20);
                }
            }
        }

        // Properties
        public string Attachment
        {
            get { return this._attachment; }
            set { this._attachment = value; }
        }

        public DateTime CloseDate
        {
            get { return this._closeDate; }
            set { this._closeDate = value; }
        }

        public string Comment
        {
            get { return this._comment; }
            set { this._comment = value; }
        }

        public Guid CompanyID
        {
            get { return this._companyID; }
            set { this._companyID = value; }
        }

        public string CostOfDeliverByQty
        {
            get { return this._costOfDeliverByQty; }
            set { this._costOfDeliverByQty = value; }
        }

        public DateTime CreateDate
        {
            get { return this._createDate; }
            set { this._createDate = value; }
        }

        public string Currency
        {
            get { return this._currency; }
            set { this._currency = value; }
        }

        public DateTime DeleteDate
        {
            get { return this._deleteDate; }
            set { this._deleteDate = value; }
        }

        public string DeliveryComment
        {
            get { return this._deliveryComment; }
            set { this._deliveryComment = value; }
        }

        public DateTime ExpireDate
        {
            get { return this._expireDate; }
            set { this._expireDate = value; }
        }

        public Guid InquiryID
        {
            get { return this._inquiryID; }
            set { this._inquiryID = value; }
        }

        public DateTime LastSaveDate
        {
            get { return this._lastSaveDate; }
            set { this._lastSaveDate = value; }
        }

        public string OtherExpenseByQty
        {
            get { return this._otherExpenseByQty; }
            set { this._otherExpenseByQty = value; }
        }

        public string OtherExpenseName
        {
            get { return this._otherExpenseName; }
            set { this._otherExpenseName = value; }
        }

        public string QuoteApp
        {
            get { return this._quoteApp; }
            set { this._quoteApp = value; }
        }

        public Guid QuoteID
        {
            get { return this._quoteID; }
            set { this._quoteID = value; }
        }

        public string QuoteStatus
        {
            get { return this._quoteStatus; }
            set { this._quoteStatus = value; }
        }

        public DateTime SubmitDate
        {
            get { return this._submitDate; }
            set { this._submitDate = value; }
        }

        public string TotalAmount
        {
            get { return this._totalAmount; }
            set { this._totalAmount = value; }
        }

        public string UnitPriceByQty
        {
            get { return this._unitPriceByQty; }
            set { this._unitPriceByQty = value; }
        }

        public Guid UserID
        {
            get { return this._userID; }
            set { this._userID = value; }
        }


        // Fields
        private string _attachment;
        private DateTime _closeDate;
        private string _comment;
        private Guid _companyID;
        private string _costOfDeliverByQty;
        private DateTime _createDate;
        private string _currency;
        private DateTime _deleteDate;
        private string _deliveryComment;
        private DateTime _expireDate;
        private Guid _inquiryID;
        private DateTime _lastSaveDate;
        private string _otherExpenseByQty;
        private string _otherExpenseName;
        private string _quoteApp;
        private Guid _quoteID;
        private string _quoteStatus;
        private DateTime _submitDate;
        private string _totalAmount;
        private string _unitPriceByQty;
        private Guid _userID;
    }


}
